package com.lyluly.coursemgmt.webmodule.controller;

import com.lyluly.coursemgmt.servicemodule.iService.IPushClickService;
import com.lyluly.coursemgmt.servicemodule.model.PushClick;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @version v1.0
 * @author clc
 */
@Controller
@RequestMapping("/pushClicks")
public class PushClickController {
    @Autowired
    private IPushClickService iPushClickService;

    /**
     * 添加一条推送点击情况记录
     * @param pushClick 推送点击情况记录实体类
     * @param response
     */
    @PostMapping
    public void addPushClick(@RequestBody PushClick pushClick, HttpServletResponse response) {
        iPushClickService.addPushClick(pushClick);
    }

    /**
     * 根据记录ID修改一条推送点击情况记录
     * @param pushClick 推送点击情况记录实体类
     * @param response
     */
    @PutMapping
    public void modifyPushClick(@RequestBody PushClick pushClick, HttpServletResponse response) {
        iPushClickService.modifyPushClick(pushClick);
    }

    /**
     * 根据记录ID删除一条推送点击情况记录
     * @param pushClickId 推送点击情况记录ID
     * @param response
     */
    @DeleteMapping("/{pushClickId}")
    public void removePushClick(@PathVariable int pushClickId, HttpServletResponse response) {
        iPushClickService.removePushClick(pushClickId);
    }

    /**
     * 根据记录ID查找一条推送点击情况记录
     * @param pushClickId 推送点击情况记录ID
     * @return 返回相应推送点击情况记录
     */
    @GetMapping("/pushClickId/{pushClickId}")
    @ResponseBody
    public PushClick findPushClickById(@PathVariable int pushClickId) {
        return iPushClickService.findPushClickById(pushClickId);
    }

    /**
     * 查找所有推送点击情况记录
     * @return 返回所有推送点击情况记录
     */
    @GetMapping
    @ResponseBody
    public List<PushClick> findPushClickList() {
        return iPushClickService.findPushClickList();
    }

    /**
     * 根据推送ID查找若干推送点击情况记录
     * @param pushId 推送ID
     * @return 返回相应推送点击情况记录
     */
    @GetMapping("/pushId/{pushId}")
    @ResponseBody
    public List<PushClick> findPushClickListByPushId(@PathVariable int pushId) {
        return iPushClickService.findPushClickListByPushId(pushId);
    }

    /**
     * 根据学生ID查找若干条推送点击情况记录
     * @param sId 学生ID
     * @return 返回相应推送点击情况记录
     */
    @GetMapping("/sId/{sId}")
    @ResponseBody
    public List<PushClick> findPushClickListBySId(@PathVariable String sId) {
        return iPushClickService.findPushClickListBySId(sId);
    }
}
